package com.jie.deletefile.Gongju;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.jie.deletefile.Gongju.comment.ScreenUtils;
import com.jie.deletefile.R;

public class TestActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView test_tv;
    private Button b_width;
    private Button b_height;
    private Button b_zhuangtai;
    private Button b_jieping;
    private Button b_jieping1;
    private ImageView b_iv;
    private Button b_appp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test2);
        initView();
    }

    private void initView() {
        test_tv = (TextView) findViewById(R.id.test_tv);
        b_width = (Button) findViewById(R.id.b_width);
        b_height = (Button) findViewById(R.id.b_height);
        b_zhuangtai = (Button) findViewById(R.id.b_zhuangtai);
        b_jieping = (Button) findViewById(R.id.b_jieping);
        b_jieping1 = (Button) findViewById(R.id.b_jieping1);
        b_iv = (ImageView) findViewById(R.id.b_iv);
        b_appp = (Button) findViewById(R.id.b_app);
        b_appp.setOnClickListener(this);

        b_width.setOnClickListener(this);
        b_height.setOnClickListener(this);
        b_zhuangtai.setOnClickListener(this);
        b_jieping.setOnClickListener(this);
        b_jieping1.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.b_width:
                int screenWidth = ScreenUtils.getScreenWidth(this);
                test_tv.setText(screenWidth+"");
                break;
            case R.id.b_height:
                int screenHeight = ScreenUtils.getScreenHeight(this);
                test_tv.setText(screenHeight+"");
                break;
            case R.id.b_zhuangtai:
                int statusHeight = ScreenUtils.getStatusHeight(this);
                test_tv.setText(statusHeight+"");
                break;
            case R.id.b_jieping:
                Bitmap bitmap = ScreenUtils.snapShotWithStatusBar(this);
                b_iv.setImageBitmap(bitmap);

                break;
            case R.id.b_jieping1:
                Bitmap bitmap1 = ScreenUtils.snapShotWithoutStatusBar(this);
                b_iv.setImageBitmap(bitmap1);
                break;
            case R.id.b_app:
                Intent intent = new Intent(TestActivity.this, AppActivity.class);
                startActivity(intent);

        }
    }
}
